package com.foreknow.demo14;

import com.foreknow.demo9.B;

import java.io.*;

/**
 * 处理流的使用
 */
public class BufferedDemo {
    public static void main(String[] args) {
        try {
            FileReader fr = new FileReader("FileCopyDemo.java");
            BufferedReader br = new BufferedReader(fr);
            FileWriter fw = new FileWriter("new_FileCopyDemo.java");
            BufferedWriter bw = new BufferedWriter(fw);
            //读取源文件的一个文本行
            String line = br.readLine();
            while (line != null) {
                //将读取到的一个文本行写进目标文件中
                bw.write(line);
                //换行
                bw.newLine();
                line = br.readLine();
            }
            //释放资源
            br.close();
            bw.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
